<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <body>

        <ui:composition template="./../templates/templatePrincipal.xhtml">

            <ui:define name="titulosesion">
                titulosesion
            </ui:define>

            <ui:define name="menuderecho">
                menuderecho
            </ui:define>

            <ui:define name="contenido">
                <h:form id="PersonaListForm">
                    <p:panel header="#{bundle.ListPersonaTitle}">
                        <p:dataTable id="datalist" value="#{personaController.items}" var="item"
                                     selectionMode="single" selection="#{personaController.selected}"
                                     paginator="true"
                                     rowKey="#{item.idpersona}"
                                     rows="10"
                                     rowsPerPageTemplate="10,20,30,40,50"
                                     >

                            <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                            <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPersonaTitle_idpersona}"/>
                                </f:facet>
                                <h:outputText value="#{item.idpersona}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPersonaTitle_nombres}"/>
                                </f:facet>
                                <h:outputText value="#{item.nombres}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPersonaTitle_apellidos}"/>
                                </f:facet>
                                <h:outputText value="#{item.apellidos}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPersonaTitle_email}"/>
                                </f:facet>
                                <h:outputText value="#{item.email}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPersonaTitle_telefono}"/>
                                </f:facet>
                                <h:outputText value="#{item.telefono}"/>
                            </p:column>
                            <f:facet name="footer">
                                <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" 
                                                 actionListener="#{personaController.prepareCreate}" update=":PersonaCreateForm" 
                                                 oncomplete="PF('PersonaCreateDialog').show()"/>
                                <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" 
                                                 update=":PersonaViewForm" oncomplete="PF('PersonaViewDialog').show()"
                                                 disabled="#{empty personaController.selected}"/>
                                <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" 
                                                 update=":PersonaEditForm" oncomplete="PF('PersonaEditDialog').show()" 
                                                 disabled="#{empty personaController.selected}"/>
                                <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" 
                                                 actionListener="#{personaController.destroy}" update=":growl,datalist" 
                                                 disabled="#{empty personaController.selected}"/>
                            </f:facet>
                        </p:dataTable>
                    </p:panel>
                </h:form>

                <ui:include src="Create.xhtml"/>
                <ui:include src="Edit.xhtml"/>
                <ui:include src="View.xhtml"/>

            </ui:define>

        </ui:composition>

    </body>
</html>
